package com.xjggb.cloud.controller;


import com.xjggb.cloud.entity.CommonResult;
import com.xjggb.cloud.entity.Payment;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class PaymentController {

   @Value("${server.port}")
    private String serverPort;


    public  static  HashMap<Long, Payment> map= new HashMap<>();

    //静态代码块
   static {
       map.put(1L,new Payment(1L,"123456789"));
       map.put(2L,new Payment(2L,"123456789"));
       map.put(3L,new Payment(3L,"123456789"));
   }

   @GetMapping(value = "/payment/{id}")
    public CommonResult<Payment> show(@PathVariable("id") Long id){
       Payment payment = map.get(id);

       return new CommonResult<Payment>(200,"成功查询"+serverPort,payment);

   }




}
